package tagdb.algorithm.tag;

import tagdb.algorithm.graph.Edge;
import tagdb.fragmentation.IonType;
import tagdb.fragmentation.SpectrumPeak;

/**
 * Created with IntelliJ IDEA.
 * User: tmuth
 * Date: 05.12.12
 * Time: 19:00
 * To change this template use File | Settings | File Templates.
 */
public class TagElement {

    /**
     * Spectrum peak.
     */
    private SpectrumPeak peak;

    /**
     * Ion type.
     */
    private IonType ionType;

    /**
     * Position of the tag element.
     */
    private int position;

    /**
     * Amino acid letter.
     */
    private char letter;

    /**
     * M/z error.
     */
    private double error;

    /**
     * Incoming edge involved.
     */
    private Edge edge;

    /**
     * Constructor of the tag element.
     * @param incomingEdge Incoming edge
     * @param ionType Ion type
     * @param position Position of the tag element.
     * @param letter Amino acid letter.
     * @param error m/z error
     */
    public TagElement(Edge incomingEdge, IonType ionType, int position, char letter, double error) {
        this.edge = incomingEdge;
        this.peak = incomingEdge.getSecondPeak();
        this.ionType = ionType;
        this.position = position;
        this.letter = letter;
        this.error = error;
    }

    /**
     * Checks if the tag element has a certain position.
     * @param position Tag element position
     * @return Condition which position is fulfilled.
     */
    public boolean hasPosition(int position){
        return this.position == position;
    }

    /**
     * Returns the (incoming) edge.
     * @return The (incoming) edge.
     */
    public Edge getEdge() {
        return edge;
    }

    /**
     * Returns the related spectrum peak.
     * @return Spectrum peak.
     */
    public SpectrumPeak getPeak() {
        return peak;
    }

    /**
     * Returns the ion type.
     * @return The ion type.
     */
    public IonType getIonType() {
        return ionType;
    }

    public int getPosition() {
        return position;
    }

    public char getLetter() {
        return letter;
    }

    public double getError() {
        return error;
    }
}
